package com;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "findServlet")
public class findServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("get");
        Users users=new Users();
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        List<Users> list=users.find();
        out.write("<table align='center' border=\"\" cellspacing=\"\" cellpadding=\"\">");
        out.write("<tr align='center'>");
        out.write("<td>"+"用户名"+"</td><td>"+
                "密码"+"</td><td>"+
                "性别"+"</td><td>"+
                "邮箱"+"</td><td>"+
                "操作"+"</td>");
        out.write("</tr>");
        for (Users users1:list
             ) {
            out.write("<tr>");
            out.write("<td>"+users1.getUsername()+"</td><td>"+
                    "*****"+"</td><td>"+
                    users1.getSex()+"</td><td>"+
                    users1.getEmail()+"</td><td algin='center'>"+
                    "<a href='/web4/delete?user="+users1.getId()+"'>删除</a>"+"</td>");
            out.write("</tr>");
        }
        out.write("</table>");
    }
}
